﻿using MangoMes.Commont.DapperHelps;
using MangoMes.Commont.Domain.Jocker;
using MangoMes.Commont.DTOs;
using MangoMes.Commont.Infrastructures.Interfaces;
using MediatR;

namespace MangoMes.Write.API.Applications.process
{
    public class processUpdateHandler:IRequestHandler<processUpdateCommond, ResultsDTO>
    {

        private readonly IBateRepository<processk> _processk;

        public processUpdateHandler(IBateRepository<processk> processk)
        {
            _processk = processk;
        }

        public async Task<ResultsDTO> Handle(processUpdateCommond request, CancellationToken cancellationToken)
        {
            try
            {
                var list = new ResultsDTO() { Code = 0 };
                DapperHelper DapperHelper = new DapperHelper();
                var gh = new processk();
                var str1 = "UPDATE processk SET ProcessName='"+request.ProcessName+"',isEnable='"+request.isEnable+"',DescriptionToreMark='"+request.DescriptionToreMark+"',ProcessInstructions='"+request.ProcessInstructions+"',ProcedureCode='"+request.ProcedureCode+"'WHERE processid="+request.processid+"";

                var getnum = _processk.Add(str1, gh, DapperHelper.MangoMesWrite);
                if(getnum!=null)
                {
                    list.Code = 1;
                }
              
                return list;
            }
            catch (Exception)
            {

                throw;
            }

          

           


        }
    }
}
